package io.renren.modules.lucky.service.impl;

import io.renren.common.validator.Assert;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.lucky.dao.AppSysAgreementDao;
import io.renren.modules.lucky.entity.AppSysAgreementEntity;
import io.renren.modules.lucky.service.AppSysAgreementService;

@Service("appSysAgreementService")
public class AppSysAgreementServiceImpl extends ServiceImpl<AppSysAgreementDao, AppSysAgreementEntity>
        implements AppSysAgreementService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<AppSysAgreementEntity> page = this.page(
                new Query<AppSysAgreementEntity>().getPage(params), new QueryWrapper<AppSysAgreementEntity>()
        );
        return new PageUtils(page);
    }

    public AppSysAgreementEntity queryByAgreementType(String agreementType) {
        AppSysAgreementEntity agreement = baseMapper.selectOne(new QueryWrapper<AppSysAgreementEntity>()
                .eq("agreement_type", agreementType));
        Assert.isNull(agreement, "协议不存在");
        return agreement;
    }

}